/**
 * 节流函数
 * @param fn 目标函数
 * @param delay 延迟时间
 * @returns 节流后函数
 */
const throttle = (fn, delay = 600) => {
  let lastExecutionTime = 0
  return () => {
    const currentTime = Date.now()
    if (currentTime - lastExecutionTime > delay) {
      fn()
      lastExecutionTime = currentTime
    }
  }
}

export { throttle }